package com.mym;

import java.io.File;
import java.io.FileFilter;

/**
 * @author miao
 * @version 1.0
 * @date 2025/4/16 11:38
 * @description
 */
public class demo1 {
    public static void main(String[] args) {
        File file = new File("C:\\ideaProjicts\\01-JavaSE\\day17-code");
        file(file);

    }
        public static void file(File file){
        if (!(file!=null&& file.exists()&&file.isDirectory())){
            throw new IllegalArgumentException("文件不存在");
        }
        File[] files = file.listFiles();
        for (File file1 : files) {
            if (file1.isFile()){
                System.out.println(file1.getName());
            }else {
                System.out.println(file1.getName());
                file(file1);
            }
        }
    }
    public static void main2(String[] args) {
        File file = new File("D:\\java\\java\\day17-code\\src\\com\\mym\\system\\User.java");
        System.out.println(file.getName());
        System.out.println(file.getPath());
        System.out.println(file.getAbsolutePath());
        System.out.println("file = " + file.getAbsolutePath());
        System.out.println("file = " + file.getPath());
        File[] files1 = file.listFiles(new FileFilter() {
            @Override
            public boolean accept(File pathname) {
                return false;
            }
        });



    }
}
